package com.wolong.share.creation.prototype;

/**
 * 原型模式
 *
 * @author wolong
 */
public class MyPrototype implements Cloneable {
    private String s;

    public MyPrototype() {
        this.s = ranString();
    }

    public String getS() {
        return s;
    }

    public void setS(String s) {
        this.s = s;
    }

    private String ranString() {
        try {
            Thread.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "s";
    }

    @Override
    protected MyPrototype clone() throws CloneNotSupportedException {
        return (MyPrototype) super.clone();
    }
}
